﻿namespace TestApp.Collections
{
    using System.Collections.Specialized;
    using System.ComponentModel;
    using Newtonsoft.Json;

    public class Pairs : System.IEquatable<Pairs>
    {
        public Pairs()
            : this(string.Empty, string.Empty)
        {
        }

        public Pairs(string key, string value)
        {
            Key = key;
            Value = value;
            Children = new PairsCollection();
        }

        public string Key { get; set; }

        public string Value { get; set; }

        public PairsCollection Children { get; private set; }

        public override string ToString()
        {
            return string.Format("{{{0} : {1}}}", Key, Value);
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as Pairs);
        }

        public override int GetHashCode()
        {
            return string.Format("{0}, {1}", Key, Value).GetHashCode();
        }

        public bool Equals(Pairs other)
        {
            return other != null && other.Key == Key && other.Value == Value;
        }
    }
}
